﻿
 //汇款姓名
function txtCustName_check(custname,msgcn)
{
	return requireFieldValid(custname,msgcn,'*');
}
//汇出金额
function txtRemitCashs_check(remitcashs,msgrc)
{
	return requireFieldValid(remitcashs,msgrc,'*')
	&& regularExpressionValid(remitcashs,NUMBER_IS_EXPRESSION,msgrc,MSG_NUMBER_IS_FORMAT_ERROR);
}
//汇款单号
function txtRemitId_check(remitid,msgri)
{
	return requireFieldValid(remitid,msgri,'*');
}
//省
function ddlProvince_check(province,msgp)
{
	return requireSelectValid(province,msgp,MSG_PROVINCE_FORMAT_ERROR);
}
//城市
function ddlCity_check(city,msgc)
{
	return requireSelectValid(city,msgc,MSG_CITY_FORMAT_ERROR);
}
//汇款日期
function ddlRemitDate_check(remitdate,msgrd)
{
	return requireFieldValid(remitdate,msgrd,'*');
}
//汇入银行
function rabBank_check()
{
	return requireRadFieldValid('rab_BankIcbc','rab_BankCcb','BankValidMsg','*');
}


//邮局汇款回告
function btnClientPost_Click(custname,msgcn,remitcashs,msgrc,remitid,msgri,remitdate,msgrd,btn)
{
    var CustNameValid=txtCustName_check(custname,msgcn);
    var RemitCashsValid=txtRemitCashs_check(remitcashs,msgrc);   
    var RemitIdValid=txtRemitId_check(remitid,msgri);
    var RemitDateValid=ddlRemitDate_check(remitdate,msgrd);    
    
    if(CustNameValid && RemitCashsValid && RemitIdValid && RemitDateValid)
    {
        document.getElementById(btn).click();
    }
}


//储蓄卡回告
function btnClientBankCard_Click(custname,msgcn,remitcashs,msgrc,province,msgp,city,msgc,remitdate,msgrd,btn)
{
    var CustNameValid=txtCustName_check(custname,msgcn);
    var RemitCashsValid=txtRemitCashs_check(remitcashs,msgrc);
    var ProvinceValid=ddlProvince_check(province,msgp);
    var CityValid=ddlCity_check(city,msgc);
    var BankValid=rabBank_check();
    var RemitDateValid=ddlRemitDate_check(remitdate,msgrd);    
    
    if(CustNameValid && RemitCashsValid && ProvinceValid && CityValid && BankValid && RemitDateValid)
    {
        document.getElementById(btn).click();
    }
}

//银行电汇回告
function btnClientBankRemit_Click(custname,msgcn,remitcashs,msgrc,province,msgp,city,msgc,remitid,msgri,remitdate,msgrd,btn)
{
    var CustNameValid=txtCustName_check(custname,msgcn);
    var RemitCashsValid=txtRemitCashs_check(remitcashs,msgrc);
    var ProvinceValid=ddlProvince_check(province,msgp);
    var CityValid=ddlCity_check(city,msgc);    
    var RemitIdValid=txtRemitId_check(remitid,msgri);
    var RemitDateValid=ddlRemitDate_check(remitdate,msgrd);    
    
    if(CustNameValid && RemitCashsValid && ProvinceValid && CityValid && RemitIdValid && RemitDateValid)
    {
        document.getElementById(btn).click();
    }
}

//国际信用卡网上支付
function btnClientCreditCard_Click(custname,msgcn,remitid,msgri,btn)
{
    var CustNameValid=txtCustName_check(custname,msgcn);   
    var RemitIdValid=txtRemitId_check(remitid,msgri);
    if(CustNameValid && RemitIdValid)
    {
        document.getElementById(btn).click();
    }
}

//汇款回告
function PopuAssure(div,h,orderid,hlk)
{
    div.style.display='block';   
    var r=getAbsolutePos(hlk);    
    var objOrderId =document.getElementById('Hid_OrderId');
    
    objOrderId.value=orderid;
    
    h.innerHTML='订单'+orderid;
     
    div.style.left=r.x-300;
    div.style.top=r.y;  
}

//订单取消
function PopuOrderCancel(div,orderid,hlk)
{
    div.style.display='block';   
    var r=getAbsolutePos(hlk);    
    var objOrderId =document.getElementById('Hid_OrderId');
    
    objOrderId.value=orderid;
     
    div.style.left=r.x-300;
    div.style.top=r.y;  
}

//隐藏汇款回告
function HideAssureDiv()
{
    var objPost =document.getElementById('div_Postassure');
    var objBankCard =document.getElementById('div_BankCardAssure');
    var objBankRemit =document.getElementById('div_BankRemitAssure');
    var objCreditCard =document.getElementById('div_CreditCard');
     if(objPost.style.display!='none')
        objPost.style.display='none';
     if(objBankCard.style.display!='none')
        objBankCard.style.display='none'; 
     if(objBankRemit.style.display!='none')
        objBankRemit.style.display='none';
     if(objCreditCard.style.display!='none')
        objCreditCard.style.display='none';
    
}


//显示关闭时间
function MyLoad()
{
   MyTimer();
}
TimeStart=5;

function MyTimer(div)
{
   if(TimeStart==0)
   {
      HidePopuMess(div)
   }
   TimeShow.innerHTML=TimeStart;
   TimeStart--;       
   var timer=setTimeout("MyTimer()",1000);
}

//隐藏地址薄div
function HidePopuMess(div)
{
     if(div.style.display!='none')
     {  
         div.style.display='none';     
         document.onclick =null;
     }
}

//显示div
function ShowDiv(obj,div)
{
    document.onclick =HidAddressMess;
     if(div.style.display!='block')
     {  
         div.style.display='block';     
     }
     var r=getAbsolutePos(obj); 
     div.style.left=r.x-300;
     div.style.top=r.y;     
}

//显示地址簿div
function PopuMess(button)
{
    document.onclick =HidAddressMess;
    document.getElementById('div_ConfirmMess').style.display='block';    
 //   var r=getPosition(button);    
    var objAddressId =document.getElementById('Hid_AddressId');
    var objCustId =document.getElementById('Hid_CustId');
    var objOperate =document.getElementById('Hid_OperateType');
    var objNumber =document.getElementById('p_AddressNumber');    
    
    objAddressId.value=button.getAttribute("addid");
    objCustId.value=button.getAttribute("custid");
    objOperate.value=button.getAttribute("operate");
    var number=button.getAttribute("number");

    if(objOperate.value=='delete')
    {objNumber.innerHTML='您真的需要删除地址'+number+'？';}
    if(objOperate.value=='default')
    {objNumber.innerHTML='您真的要把地址'+number+'设为常用地址吗？';}    
    
        GetPos(button, document.getElementById('div_ConfirmMess'));
   
    
}


function GetPos(inputObj, divObj)
	{
		
	     
		var inputObj = getPosition(inputObj);		
		
		if(IsIE())
		{
			divObj.style.left = inputObj.x -1 +"px";
			divObj.style.top = inputObj.y + 20+"px";
		}
		else
		{
			divObj.style.left = inputObj.x+"px";
			divObj.style.top = inputObj.y + 20+"px";
		}
	
	}
	

function getAbsolutePos(el)
{
 var SL = 0, ST = 0;
  var is_div = /^div$/i.test(el.tagName);
  if (is_div && el.scrollLeft)
   SL = el.scrollLeft;
  if (is_div && el.scrollTop)
    ST = el.scrollTop;
  var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
  if (el.offsetParent)
  {
     var tmp = this.getAbsolutePos(el.offsetParent);
     r.x += tmp.x;
     r.y += tmp.y;
  }
  return r;
}


function getPosition(o){
	var nLt=0;
	var nTp=0;
	var offsetParent = o;
	while (offsetParent!=null && offsetParent!=document.body) {
			nLt+=offsetParent.offsetLeft;
			nTp+=offsetParent.offsetTop;
 
	if(!IsNav()){
		parseInt(offsetParent.currentStyle.borderLeftWidth)>0?nLt+=parseInt(offsetParent.currentStyle.borderLeftWidth):"";
		parseInt(offsetParent.currentStyle.borderTopWidth)>0?nTp+=parseInt(offsetParent.currentStyle.borderTopWidth):"";
 
		}
 
	offsetParent=offsetParent.offsetParent;
	//alert(offsetParent.tagName);
 }
 
  return {x:nLt, y:nTp};
  
//alert("ID:"+o.id+"\n\nL:"+nLt+" T:"+nTp+"\nW:"+o.offsetWidth+" H:"+o.offsetHeight);
}


function HidAddressMess()
{
  //  hideMsgBox();
    //if(callback != null) callback();
     if(document.getElementById('div_ConfirmMess').style.display!='none')
     
         document.getElementById('div_ConfirmMess').style.display='none';    
          
    // if(document.getElementById('div_AboutMess').style.display!='none')
     //    document.getElementById('div_AboutMess').style.display='none';     
}


//<![CDATA[ 
    function fDragging(obj, e, limit){ 
        if(!e) e=window.event; 
        var x=parseInt(obj.style.left); 
        var y=parseInt(obj.style.top); 
         
        var x_=e.clientX-x; 
        var y_=e.clientY-y; 
         
        if(document.addEventListener){ 
            document.addEventListener('mousemove', inFmove, true); 
            document.addEventListener('mouseup', inFup, true); 
        } else if(document.attachEvent){ 
            document.attachEvent('onmousemove', inFmove); 
            document.attachEvent('onmouseup', inFup); 
        } 
         
        inFstop(e);     
        inFabort(e) 
         
        function inFmove(e){ 
            var evt; 
            if(!e)e=window.event; 
             
            if(limit){ 
                var op=obj.parentNode; 
                var opX=parseInt(op.style.left); 
                var opY=parseInt(op.style.top); 
                 
                if((e.clientX-x_)<0) return false; 
                else if((e.clientX-x_+obj.offsetWidth+opX)>(opX+op.offsetWidth)) return false; 
                 
                if(e.clientY-y_<0) return false; 
                else if((e.clientY-y_+obj.offsetHeight+opY)>(opY+op.offsetHeight)) return false; 
                //status=e.clientY-y_; 
            } 
             
            obj.style.left=e.clientX-x_+'px'; 
            obj.style.top=e.clientY-y_+'px'; 
             
            inFstop(e); 
        } // shawl.qiu script 
        function inFup(e){ 
            var evt; 
            if(!e)e=window.event; 
             
            if(document.removeEventListener){ 
                document.removeEventListener('mousemove', inFmove, true); 
                document.removeEventListener('mouseup', inFup, true); 
            } else if(document.detachEvent){ 
                document.detachEvent('onmousemove', inFmove); 
                document.detachEvent('onmouseup', inFup); 
            } 
             
            inFstop(e); 
        } // shawl.qiu script 
  
        function inFstop(e){ 
            if(e.stopPropagation) return e.stopPropagation(); 
            else return e.cancelBubble=true;             
        } // shawl.qiu script 
        function inFabort(e){ 
            if(e.preventDefault) return e.preventDefault(); 
            else return e.returnValue=false; 
        } // shawl.qiu script 
    } 
//]]> 